<?php
    include_once ("../dao/categoryDAO.php");

    function getNonParentCategory() {
        return loadNonParentCategory();
    }

    function getCategoryByID($cateID) {
        $result = loadCategoryByID($cateID);
        return ConnectionManager::getInstance()->fetchArray();
    }

    function getCategoriesBy($keyword, $categoryID, $start_position, $row_per_page){
        return findBy($keyword, $categoryID, $start_position, $row_per_page);
    }

    function countNumOfCategoryByName($keyword){
        return countByName($keyword);
    }

    function deleteCategory($id){
        return delete($id);
    }

    function getTotalCategory() {
        return countTotalCategory();
    }

    function getParentCategory() {
        return loadParentCategory();
    }

    function getChildCategory($parentID) {
        return loadChildCategory($parentID);
    }
    
    function updateCategory($catID, $parentID, $name, $description){
        return update($catID, $parentID, $name, $description);
    }
    
    function insertCategory($parentID, $name, $description){
        return insert($parentID, $name, $description);
    }
    
    function getRootCategory(){
        return loadRootCategory();
    }
    
?>